import request from '@/utils/request'
import type { LeaderboardItem, ApiResponse } from '@/types'

export const socialApi = {
  // 获取排行榜
  getLeaderboard(params?: {
    type?: string
    school?: string
    grade?: string
    period?: string
    limit?: number
  }): Promise<ApiResponse<LeaderboardItem[]>> {
    return request.get('/social/leaderboard', { params })
  },
  
  // 获取用户排名
  getUserRank(type?: string): Promise<ApiResponse> {
    return request.get('/social/rank', { params: { type } })
  },
  
  // 搜索用户
  searchUsers(keyword: string, limit?: number): Promise<ApiResponse> {
    return request.get('/social/search', { params: { keyword, limit } })
  },
  
  // 添加好友
  addFriend(friendId: number): Promise<ApiResponse> {
    return request.post('/social/friends/add', { friendId })
  },
  
  // 获取好友列表
  getFriendsList(): Promise<ApiResponse> {
    return request.get('/social/friends')
  },
  
  // 获取好友请求
  getFriendRequests(): Promise<ApiResponse> {
    return request.get('/social/friends/requests')
  },
  
  // 处理好友请求
  handleFriendRequest(requestId: number, action: 'accept' | 'reject'): Promise<ApiResponse> {
    return request.post('/social/friends/handle', { requestId, action })
  }
}

